//


import UIKit

class WP_InfoViewController: WP_BasicViewController,UITableViewDelegate,UITableViewDataSource {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setNavTitle("Personal center")
        // Do any additional setup after loading the view.
        
        self.view.addSubview(pTableView)
    }
    
    lazy var pTableView:UITableView = {
        let tableview = UITableView(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenHeight - kNavBarHeight), style: .plain)
        tableview.delegate = self
        tableview.dataSource = self
        tableview.tableFooterView = UIView()
        tableview .register(UITableViewCell.classForCoder(), forCellReuseIdentifier:"cell")
        tableview.rowHeight = 60
        return tableview
        
    }()
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 2
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell:UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
        cell.accessoryType = .disclosureIndicator
        if indexPath.row == 0 {
            cell.textLabel?.text = "About"
            
        }else {
            cell.textLabel?.text = "Feedback"
        }
        
        return cell
    }
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 120
    }
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        let view = UIView()
        let img = UIImageView.init(frame: CGRect(x: kScreenWidth/2-30, y: kRatioHeight(20), width: kRatioWidth(60), height: kRatioHeight(60)))
        img.backgroundColor = UIColor.lightGray
        img.image = UIImage.init(named: "logo")
        view.addSubview(img)
        let label = UILabel.init(frame: CGRect(x: 0, y: img.frame.maxY+10, width: kScreenWidth, height: 20))
        label.textAlignment = .center
        label.font = FontPFRegular(16)
        label.text = "versions:\(Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "")"
        view.addSubview(label)
        
        return view
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        
        if indexPath.row == 0 {
            let vc = WP_AboutViewController()
            self.navigationController?.pushViewController(vc, animated: true)
        }else{
            let vc = WP_FeedbackViewController()
            self.navigationController?.pushViewController(vc, animated: true)
        }
    }
    
    /*
     // MARK: - Navigation
     
     // In a storyboard-based application, you will often want to do a little preparation before navigation
     override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
     // Get the new view controller using segue.destination.
     // Pass the selected object to the new view controller.
     }
     */
    
}
